<template>
  <h1>登录界面</h1>

  用户名:<input type="text" v-model="userName"><br/>
  密码:<input type="text" v-model="password"><br/>

  <button @click="login">登录</button>

</template>

<script setup>
import { useRouter } from "vue-router";
const router = useRouter();

import {getData} from "../../js/remote";

const userName = $ref('')
const password = $ref('')

function login(){
  getData('/login',{userName:userName,password:password}).then(function (res) {
    if(res.code == 1000){
      localStorage.setItem('token',res.data)
      router.push('/')
    }else{
      alert('登录失败:'+res.msg)
    }
  })


}

</script>

<style scoped>

</style>